package interpreter;

import heap.Heap;

import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Map;

public class CollectInst implements Instruction {


	@Override
	public void execute() {
		try {
			
			Class<?> collectorClass = Class.forName("Collector");
			Class<?> myCollectorClass = Class.forName("MyCollector");
			Object myCollector = myCollectorClass.newInstance();
			Class<?> npjClass = Class.forName("NPJ");
			Object npj = npjClass.newInstance();
			
			Method collectMethod = npjClass.getMethod("collect", new Class[] { int[].class, collectorClass, Map.class });
			collectMethod.invoke(npj, null, myCollector, Collections.emptyMap());
			
		} catch(Exception ex) {
			throw new RuntimeException("fatal invocation exception!", ex);
		}
	}

}
